package com.example.saiweisi.controller.systemAdminController;

import com.example.saiweisi.common.Result;
import com.example.saiweisi.controller.request.ClothesMaterialRequest;
import com.example.saiweisi.controller.request.PageBaseRequest;
import com.example.saiweisi.model.ClothesMaterial;
import com.example.saiweisi.model.VipKind;
import com.example.saiweisi.service.interf.IClothesMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/clothesmaterial")
@RestController
@CrossOrigin
@Slf4j
public class ClothesMaterialController {
    @Autowired
    IClothesMaterialService clothesMaterialService;
    //分页查询所有衣服材质
    @GetMapping("/page")
    public Result page(ClothesMaterialRequest clothesMaterialRequest) {
        Result success = Result.success(clothesMaterialService.page(clothesMaterialRequest));
        return success;
    }

    /**
     * 查询所有的衣服材质
     * @return 返回json
     */
    @GetMapping("/getall")
    public Result getall() {
        return Result.success(clothesMaterialService.getall());
    }
    //添加衣物材质种类
    @PostMapping("/add")
    public Result addclothesMaterial(@RequestBody ClothesMaterial clothesMaterial){
        clothesMaterialService.addclothesMaterial(clothesMaterial);
        return Result.success();
    }
    //删除衣物材质
    @DeleteMapping("/delete{clothesMaterialId}")
    public Result deleteclothesMaterial(@PathVariable Integer clothesMaterialId){
        clothesMaterialService.deleteclothesMaterial(clothesMaterialId);
        return Result.success();
    }
    //批量删除
    @PostMapping("/deletes")
    public Result deletesclothesMaterial(@RequestBody List<Integer> clothesMaterialIds){
        clothesMaterialService.deletesclothesMaterial(clothesMaterialIds);
        return Result.success();
    }
    @PutMapping("/save")
    public Result saveclothesMaterial(@RequestBody List<ClothesMaterialRequest> clothesMaterialRequestList){
        clothesMaterialService.saveclothesMaterial(clothesMaterialRequestList);
        return Result.success();
    }
}
